package com.dao.impl;

import java.util.List;
import java.util.Map;

import com.beans.Company;
import com.beans.User;
import com.dao.CompanyDao;

public class CompanyDaoImpl extends UniversalDaoImpl implements CompanyDao {

	public Company login(String name, String pwd) {
		Company c=null;
		String sql="from com.beans.Company where loginName=? and pwd=?";
		Object[] p=new Object[]{name,pwd};
		List l=this.getHibernateTemplate().find(sql, p);
		if(l!=null&&l.size()>0)
			c=(Company)l.get(0);
		return c;
	}

	public boolean companyPwd(int userid, String oldPwd, String newPwd) {
		String sql="update j_company set pwd=?,pwd1=pwd,pwd2=pwd1,pwd3=pwd2 where id=? and pwd=?";
		int t=getJdbcTemplate().update(sql,new Object[]{newPwd,userid,oldPwd});
		if(t==1)
			return true;
		return false;
	}
}